package com.gy.spark.core.others

import org.apache.spark.{SparkConf, SparkContext}

object AccumulatorOperator {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf()
    conf.setMaster("local").setAppName(this.getClass.getSimpleName)
    val sc = new SparkContext(conf)

    val accumulator = sc.longAccumulator("myValue")
    sc.textFile("./spark/input/words.txt").foreach { x => {
      accumulator.add(1)
    }
    }
    println(accumulator.value)
    sc.stop()
  }
}